//
//  BaseViewController.m
//  HomeFurnishing
//
//  Created by dllo on 16/3/25.
//  Copyright © 2016年 YMing. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)dealloc
{
    [NOTIFICATION_CENTER removeObserver:self name:@"night" object:nil];
    [NOTIFICATION_CENTER removeObserver:self name:@"day" object:nil];
    [super dealloc];
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //注册通知
    [NOTIFICATION_CENTER addObserver:self selector:@selector(night:) name:@"night" object:nil];
    [NOTIFICATION_CENTER addObserver:self selector:@selector(day:) name:@"day" object:nil];
    //获取本地的模式判断字段
    BOOL isNight = [USERDEFAULTS boolForKey:@"isNight"];
    if (isNight) {
        //self.view.backgroundColor = [UIColor lightGrayColor];
        self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    }else{
        //self.view.backgroundColor = [UIColor whiteColor];
        self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
    }
}
//通知方法
-(void)night:(NSNotification *)night
{
    //self.view.backgroundColor = [UIColor lightGrayColor];
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    self.tabBarController.tabBar.barStyle = UIBarStyleBlack;
    [USERDEFAULTS setBool:YES forKey:@"isNight"];
}

-(void)day:(NSNotification *)day
{
    //self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
    self.tabBarController.tabBar.barStyle = UIBarStyleDefault;
    [USERDEFAULTS setBool:NO forKey:@"isNight"];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
